/* Copyright (c) 2025 Beijing Semidrive Technology Corporation
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/** *****************************************************************************************************
 *  \file     Sent_Types.h                                                                              *
 *  \brief    This file contains interface header for Sent MCAL driver                                  *
 *                                                                                                      *
 * <table>                                                                                              *
 * <tr><th>Date           <th>Version                                                                   *
 * <tr><td>2024/10/30     <td>1.0.0                                                                     *
 * </table>                                                                                             *
 *******************************************************************************************************/
#ifndef SENT_TYPES_H
#define SENT_TYPES_H
/********************************************************************************************************
 *                                      Include header files                                            *
 *******************************************************************************************************/
#include "Platform_Types.h"
#include "Sent_Ip.h"

/**
 *  \addtogroup SENT_MACRO SENT macro.
 *  \{
 */
/********************************************************************************************************
 *                                 Global Macro definition                                              *
 *******************************************************************************************************/
/**
 *  \name SENT Driver ID Info
 *  \{
 */
/** \brief Semidrive Vendor ID */
#define SENT_VENDOR_ID    (0x8cU)
/** \brief SENT Driver Module ID */
#define SENT_MODULE_ID   (2052U)
/** \brief SENT Driver Instance ID */
#define SENT_INSTANCE_ID   ((uint8)0U)
/** \} */

/**
 *  \name SENT Service Ids
 *
 *  The Service Id is one of the argument to Det_ReportError function and
 *  is used to identify the source of the error
 *  \{
 */
/** \brief Sent_TimeStampInit() API Service ID */
#define SENT_TIME_STAMP_INIT_ID ((uint8)0x00U)
/** \brief Sent_TimeStampLatch() API Service ID */
#define SENT_TIME_STAMP_LATCH_ID ((uint8)0x01U)
/** \brief Sent_TimeStampCntClr() API Service ID */
#define SENT_TIME_STAMP_CLR_ID ((uint8)0x02U)
/** \brief Sent_TimeStampGet() API Service ID */
#define SENT_TIME_STAMP_GET_ID ((uint8)0x03U)
/** \brief Sent_ChannelInit() API Service ID */
#define SENT_CHANNEL_INIT_ID ((uint8)0x04U)
/** \brief Sent_ChannelDeInit() API Service ID */
#define SENT_CHANNEL_DEINIT_ID ((uint8)0x05U)
/** \brief Sent_ChannelReadData() API Service ID */
#define SENT_CHANNEL_READ_DATA_ID ((uint8)0x06U)
/** \brief Sent_ChannelReadSerialData() API Service ID */
#define SENT_CHANNEL_READ_SERIAL_DATA_ID ((uint8)0x07U)
/** \brief Sent_GetVersionInfo() API Service ID */
#define SENT_GET_VERSION_INFO_ID ((uint8)0x08U)
/** \brief Sent_ChannelActualTick() API Service ID */
#define SENT_CHANNEL_ACTUAL_TICK_ID ((uint8)0x09U)
/** \brief Sent_ChannelUpdateTick() API Service ID */
#define SENT_CHANNEL_UPDATA_TICK_ID ((uint8)0x0aU)
/** \brief Sent_ChannelDmaReadData API Service ID */
#define SENT_CHANNEL_DMA_READ_DATA_ID ((uint8)0x0bU)
/** \brief Sent_ChannelDmaReadSerialData API Service ID */
#define SENT_CHANNEL_DMA_READ_SERIAL_DATA_ID ((uint8)0x0cU)
/** \} */

/**
 *  \name Sent Error Codes
 *
 *  Error codes returned by SENT functions
 *  \{
 */
/** \brief ERROR Description:API service called with invalid(Null_Ptr) data buffer pointer. */
#define SENT_E_PARAM_POINTER   ((Std_ReturnType)0x02U)
/** \brief ERROR Description:API service is called but the module is already initialized. */
#define SENT_E_ALREADY_INITIALIZED   ((Std_ReturnType)0x03U)
/** \brief ERROR Description:API called with invalid channel. */
#define SENT_E_PARAM_CHANNEL   ((Std_ReturnType)0x04U)
/** \brief ERROR Description:API service used without module initialization */
#define SENT_E_UNINIT    ((uint8)0x05U)
/** \brief ERROR Description:API service resource error */
#define SENT_E_RES    ((uint8)0x06U)
/** \brief ERROR Description:API service parameter error */
#define SENT_E_PARAMETER    ((uint8)0x07U)
/** \} */
/** \} */

/** cache line size */
#define SENT_CACHE_LINE  (CACHE_SIZE)

/**
 *  \addtogroup SENT_CFG SENT Configuration.
 *  \{
 */
/********************************************************************************************************
 *                                  Global Types definition                                             *
 *******************************************************************************************************/
/** \brief Type describing the SENT time stamp channel */
typedef uint32 Sent_TimeStampChannelType;

/** \brief Type describing the SENT time stamp value */
typedef uint32 Sent_TimeStampValueType;

/** \brief Type describing the SENT channel */
typedef uint32 Sent_ChannelType;

/** \brief Type describing the SENT channel actual tick */
typedef uint32 Sent_ChannelActualTickType;

/** \brief  Notification callback function pointer  */
typedef void(*Sent_NotificationType)(Sent_Ip_ChannelStaType chnSta);

/**
 *  \brief SENT time stamp status
 */
typedef enum
{
    /** SENT module is uninitialized */
    SENT_TIME_STAMP_UNINIT = 0U,
    /** SENT Normal operation mode of the SENT */
    SENT_TIME_STAMP_INITED = 1U
} Sent_TimeStampStaType;

/**
 *  \brief SENT channel status
 */
typedef enum
{
    /** SENT module is uninitialized */
    SENT_CHANNEL_UNINIT = 0U,
    /** SENT Normal operation mode of the SENT */
    SENT_CHANNEL_INITED = 1U
} Sent_ChannelStaType;

/** \brief  time stamp config. */
typedef struct
{
    /** base address */
    uint32 base;
    /** crossover factor */
    uint32 div;
    /** core ID */
    uint32 coreId;
} Sent_TimeStampCfgType;
/** \} */

/** \brief  sent channel config. */
typedef struct
{
    /** channel config */
    Sent_Ip_ChnCfgType channelCfg;
    /** core ID */
    uint32 coreId;
    /** notification */
    Sent_NotificationType notification;
    /** serial under run Interrupt */
    boolean serUnderRunInt;
    /** nibble under run Interrupt */
    boolean nibUnderRunInt;
    /** serial data ready interupt */
    boolean serReadyInt;
    /** nibble data ready interrupt */
    boolean nibReadyInt;
    /** nibble dma data buff len */
    uint32 DmaNibbleBuffLen;
    /** nibble dma data buff */
    Sent_Ip_NibDataType *DmaNibbleBuff;
    /** serial dma data buff len */
    uint32 DmaSerBuffLen;
    /** serial dma data buff */
    Sent_Ip_SerDataType *DmaSerBuff;
} Sent_ChannelCfgType;
/** \} */

#endif /* SENT_TYPES_H */
/* End of file */
